package com.aegean.MonitorExamSYS.android.action;

import java.util.ArrayList;
import javax.annotation.Resource;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.aegean.MonitorExamSYS.android.business.AndroidBusiness;
import com.aegean.MonitorExaxSYS.model.ExamineeValue;
import com.aegean.MonitorExaxSYS.model.MonitorValue;
import com.opensymphony.xwork2.ActionSupport;

@Controller("LoginUserForAndroid")
@Scope("prototype")
public class LoginUserForAndroid extends ActionSupport {
	@Resource
	AndroidBusiness business;
	private int status;// 确定登陆Android端用户的真实身份，1代表考生，2代表监考人员
	private MonitorValue monitor;
	private ExamineeValue examinee;
	private String userName;
	private String userPwd;
	private int unit_Id;
	private boolean success;

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public int getUnit_Id() {
		return unit_Id;
	}

	public void setUnit_Id(int unit_Id) {
		this.unit_Id = unit_Id;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getUserPwd() {
		return userPwd;
	}

	public void setUserPwd(String userPwd) {
		this.userPwd = userPwd;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public MonitorValue getMonitor() {
		return monitor;
	}

	public void setMonitor(MonitorValue monitor) {
		this.monitor = monitor;
	}

	public ExamineeValue getExaminee() {
		return examinee;
	}

	public void setExaminee(ExamineeValue examinee) {
		this.examinee = examinee;
	}

	public String loginExaminee() throws Exception {
		// TODO Auto-generated method stub
		Object obj = business.loginUserForAndroid(status, userName, userPwd,
				unit_Id);
		if (obj instanceof ExamineeValue && obj != null) {
			examinee = (ExamineeValue) obj;
			success=true;
		} else {
            success=false;
		}
		return SUCCESS;
	}

	public String loginMonitor() throws Exception {
		// TODO Auto-generated method stub
		Object obj = business.loginUserForAndroid(status, userName, userPwd,
				unit_Id);
		if (obj instanceof MonitorValue && obj != null) {
			monitor = (MonitorValue) obj;
			success=true;
		} else {
            success=false;
		}
		return SUCCESS;
	}

}
